﻿using Azure.Core;
using MediatR;
using WMS.API.Application.Command.StocktakingManagement.PendingOrder;
using WMS.Domain.Entities.StocktakingManagement;
using WMS.ErrorCode;
using WMS.Interfactructure.Interfaces;

namespace WMS.API.Application.CommandHandlers.StocktakingManagement
{
    /// <summary>
    /// 删除待盘点订单命令处理-xzc
    /// </summary>
    public class DeletePendingOrdersCommandHandlers : IRequestHandler<DeletePendingOrdersCommand, APIResult<int>>
    {
        private readonly IBaseRepository<PendingOrders> _pendingordersRepository;

        public DeletePendingOrdersCommandHandlers(IBaseRepository<PendingOrders> pendingordersRepository)
        {
            _pendingordersRepository = pendingordersRepository;
        }

        public async Task<APIResult<int>> Handle(DeletePendingOrdersCommand request, CancellationToken cancellationToken)
        {
            APIResult<int> result = new APIResult<int>("删除待盘点订单成功");

            result.Message = "删除待盘点订单成功";
            result.Code = ResultCode.Success;

            await _pendingordersRepository.DeleteAsync(request.Id);

            return await Task.FromResult(result);
        }
    }
}
